//
//  DDImagePickerCell.m
//  PrivateCloud
//
//  Created by mars on 13-11-7.
//  Copyright (c) 2013年 sarah doo. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "DDImagePickerCell.h"
#include <AssetsLibrary/AssetsLibrary.h>

@implementation DDImagePickerCell

@synthesize model,imageView,button;

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createViews];
    }
    return  self;
}

-(void)createViews{
    imageView = [[UIImageView alloc]initWithFrame:CGRectMake(20, 0, 50,50)];
    [self.contentView addSubview:imageView];
    UIImage* image = [UIImage imageNamed:@"call.png"];
    [imageView setImage:image];
    
    button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake([[UIScreen mainScreen] bounds].size.width - 50, 0, 40, 40);
    [button setImage:[UIImage imageNamed:@"check_false.png"] forState:UIControlStateNormal];
    [button setUserInteractionEnabled:NO];
    
    [self.contentView addSubview:button];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
}

- (void)setModel:(DDImagePickerModel *)_model {
    if (model != _model) {
        [model release];
        model = [_model retain];
    }
    
    [self.imageView setImage:[UIImage imageWithCGImage:[model.asset thumbnail]]];
 
    if (model.isSelected) {
        [button setImage:[UIImage imageNamed:@"check_true.png"] forState:UIControlStateNormal];
    } else {
        [button setImage:[UIImage imageNamed:@"check_false.png"] forState:UIControlStateNormal];
    }
}

-(BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event{
    NSLog(@"server--------------");
    return true;
}

@end
